<%@ page language="java" pageEncoding="UTF-8" %>
<html>
<head>
	<%
		String baseUrl = request.getContextPath();
		String addressId = request.getParameter("addressId");
	%>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript">
		$(document).ready(function(){
			// 工具栏
		    var toolbar = new Ext.Toolbar({
		    	renderTo: 'editphoneListToolBarDiv',
		    	items: [
				    new Ext.Button({
					    id: 'editphoneList-save-button',
						text: '保存',
						iconCls: 'tick'
					}),
					new Ext.Button({
					    id: 'editphoneList-cancel-button',
						text: '取消',
						iconCls: 'cancel'
					})
				]
			});
			
		 	// 编辑通讯录Form
			var editPhoneFormPanel = new Ext.FormPanel({
				renderTo: 'editPhoneFormDiv',
		        labelWidth: 50,
		        border: false,
		        bodyStyle: 'background-color:transparent;',
		        //url: '${pageContext.request.contextPath}/updateUserInfor.action',
		        url: '',
		        items: [{
		            layout:'form',
		            border: false,
		            bodyStyle: 'padding:5px;background-color:transparent;',
		            items:[{// id
			               xtype:'hidden',
			               id:'id',
			               name: 'id'
			           },{// 通讯录组名
			               xtype:'textfield',
			               id:'name',
			               name:'name',
			               fieldLabel:'组名称',
			               anchor:'98%',
			               allowBlank:false,
			               disabled:true
			           },{// 电话
			               xtype:'textarea',
			               id:'phone',
			               name:'phone',
			               fieldLabel:'电话',
			               anchor:'98%',
			               allowBlank:false,
			               maxLength: 200
			           }]
		        }]
		    });

		    // 发送请求-form初期化
			Anynote.ajaxRequest({
				baseUrl: '<%=baseUrl %>',
				baseParams: {addressId:'<%=addressId%>'},
				action: '${pageContext.request.contextPath}/getAddressID.action',
				callback: function(jsonResult){
					var form = editPhoneFormPanel.getForm();
					form.setValues(jsonResult);
				}
			});

		    // 保存按钮
		    $("#editphoneList-save-button").click(function(){
			    var form = editPhoneFormPanel.getForm();
			    if(form.isValid()){
			    	// 发送请求
					Anynote.ajaxRequest({
						baseUrl: '<%=baseUrl %>',
						baseParams: form.getValues(),
						action: '${pageContext.request.contextPath}/updatePhoneListInfor.action',
						callback: function(jsonResult){
						    phoneListGrid.getStore().reload();
							editPhonegroupWindow.close();
						},
						showWaiting: true,
						failureMsg: '保存失败.'
					});
				}
			});
			
		 	// 取消按钮
		    $("#editphoneList-cancel-button").click(function(){
		    	editPhonegroupWindow.close();
			});
		});
	</script>
</head>
<body>
<div id="editUserDiv" style="width:100%;height:100%;">
	<div id="editphoneListToolBarDiv"></div>
	<div id="editPhoneFormDiv""></div>
</div>

</body>
</html>